# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=SDL2_mixer
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.0.0
pkgrel=4
pkgdesc="A simple multi-channel audio mixer (Version 2) (mingw-w64)"
arch=('any')
url="http://www.libsdl.org/projects/SDL_mixer"
license=("MIT")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc" "${MINGW_PACKAGE_PREFIX}-pkg-config")
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-SDL2"
         "${MINGW_PACKAGE_PREFIX}-libvorbis"
         "${MINGW_PACKAGE_PREFIX}-libmodplug"
         "${MINGW_PACKAGE_PREFIX}-smpeg2"
         "${MINGW_PACKAGE_PREFIX}-flac"
         "${MINGW_PACKAGE_PREFIX}-fluidsynth")
options=('staticlibs' 'strip')
noextract=(${_realname}-${pkgver}.tar.gz)
source=("$url/release/${_realname}-${pkgver}.tar.gz")
md5sums=('65f6d80df073a1fb3bb537fbda031b50')

prepare() {
  cd $startdir/
  [ -d $srcdir/${_realname}-$pkgver ] || tar -xzvf ${_realname}-${pkgver}.tar.gz -C $srcdir || true

  cd "${srcdir}"/${_realname}-${pkgver}

  sed -i "s|/etc/timidity|/etc/timidity++|g" timidity/config.h
  sed -i "s|/etc/timidity++.cfg|/etc/timidity++/timidity.cfg|g" timidity/config.h
}

build() {
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"
  "${srcdir}"/${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --enable-shared \
    --enable-static
  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR="$pkgdir" install
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
